package com.ungao.tools.generator.engine.config;

public class DefaultTemplateConfig {

    /**
     * 默认配置
     */
    private TemplateConfig templateConfig;

    /**
     * 构造函数
     *
     * @param templateConfig
     */
    public DefaultTemplateConfig(TemplateConfig templateConfig) {
        this.templateConfig = this.config(templateConfig);
    }

    /**
     * 获取配置
     *
     * @return
     */
    public TemplateConfig config() {
        return this.templateConfig;
    }

    /**
     * 默认后缀
     *
     * @param configBuilder
     * @return
     */
    private TemplateConfig config(TemplateConfig configBuilder) {
        String moduleSuffix = configBuilder.getModuleSuffix();
        if (moduleSuffix == null) {
            configBuilder.setModuleSuffix("Bean");
        }
        String serviceSuffix = configBuilder.getServiceSuffix();
        if (serviceSuffix == null) {
            configBuilder.setServiceSuffix("Service");
        }
        String controlSuffix = configBuilder.getControlSuffix();
        if (controlSuffix == null) {
            configBuilder.setControlSuffix("Controller");
        }
        String mapperSuffix = configBuilder.getMapperSuffix();
        if (mapperSuffix == null) {
            configBuilder.setMapperSuffix("Mapper");
        }
        String implSuffix = configBuilder.getImplSuffix();
        if (implSuffix == null) {
            configBuilder.setImplSuffix("Impl");
        }
        return configBuilder;
    }
}
